﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PRE.Catalog
{
    public partial class frmLTB_load : DevExpress.XtraEditors.XtraForm
    {
        DAL.Entities_DAL.LOAI_TB_DAL _dal = new DAL.Entities_DAL.LOAI_TB_DAL();
        BLL.Entities_BLL.Xu_ly_chung _chung = new BLL.Entities_BLL.Xu_ly_chung();

        public frmLTB_load()
        {
            InitializeComponent();
        }

        private void frmLTB_load_Load(object sender, EventArgs e)
        {

        }

        private void cmdLuu_Click(object sender, EventArgs e)
        {
            var name = _chung.Proper(txtTenltb.Text);


            var o = new DAL.Entities.LOAI_TB()
            {
                MA_LTB = txtMaltb.Text,
                TEN_LTB = name,
            };

            var oki = _dal.Insert(o);
            if (oki)
            {
                MessageBox.Show("Đã lưu thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                MessageBox.Show("Lỗi! Lưu thất bại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Error);

            }
        }

        private void cmdLammoi_Click(object sender, EventArgs e)
        {
            txtMaltb.Text = null;
            txtTenltb.Text = null;
        }

        private void cmdThoat_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
